type
        stackType = longint;

        stack = object
                a : array of stackType;
                procedure init();
                procedure push(v : stackType);
                procedure pop();
                function top() : stackType;
                function empty() : boolean;
        end;

procedure stack.init();
begin
        setlength(a, 0);
end;

procedure stack.push(v : stackType);

var
        tt : longint;

begin
        tt := length(a);
        setlength(a, tt + 1);
        a[tt] := v;
end;

procedure stack.pop();
begin
        setlength(a, length(a) - 1);
end;

function stack.top() : stackType;
begin
        result := a[length(a) - 1];
end;

function stack.empty() : boolean;
begin
        result := length(a) = 0;
end;